package com.dinzeer.pseudoedge_break_dawn.register;

import com.dinzeer.pseudoedge_break_dawn.Pseudoedge_break_dawn;
import com.dinzeer.pseudoedge_break_dawn.sa.DriveSumon;
import com.dinzeer.pseudoedge_break_dawn.sa.Thrust;
import com.dinzeer.pseudoedge_break_dawn.sa.SommonSwordSommon;
import mods.flammpfeil.slashblade.SlashBlade;
import mods.flammpfeil.slashblade.ability.StunManager;
import mods.flammpfeil.slashblade.init.DefaultResources;
import mods.flammpfeil.slashblade.registry.combo.ComboState;
import mods.flammpfeil.slashblade.slasharts.CircleSlash;
import mods.flammpfeil.slashblade.slasharts.JudgementCut;
import mods.flammpfeil.slashblade.util.AttackManager;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;

import static com.dinzeer.pseudoedge_break_dawn.Pseudoedge_break_dawn.MODID;

public class PbdComboState {
    public static final DeferredRegister<ComboState> COMBO_STATES =
            DeferredRegister.create(ComboState.REGISTRY_KEY,MODID);



    public static final RegistryObject<ComboState> ALL_REUSE = COMBO_STATES.register
            (
                    "all_reuse",
                    ComboState.Builder.newInstance().startAndEnd(459, 488).priority(50)
                            .motionLoc(DefaultResources.ExMotionLocation).next(entity -> SlashBlade.prefix("none"))
                            .nextOfTimeout(entity -> SlashBlade.prefix("none"))
                            .addTickAction(ComboState.TimeLineTickAction.getBuilder().put(0, AttackManager::playQuickSheathSoundAction).build())
                            .releaseAction(ComboState::releaseActionQuickCharge)::build
            );

    public static final RegistryObject<ComboState> ThrustEEX = COMBO_STATES.register("thrusteex",
            ComboState.Builder.newInstance().startAndEnd(400, 459).priority(50)
                    .motionLoc(DefaultResources.ExMotionLocation)
                    .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                    .nextOfTimeout(entity -> Pseudoedge_break_dawn.prefix("all_reuse"))
                    .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                            .put(1, (entityIn) -> AttackManager.doSlash(entityIn, -30F, Vec3.ZERO, false, false, 0.1F))
                            .put(2, (entityIn) -> Thrust.doSlash(entityIn,30F*3))
                            .build())
                    .addHitEffect(StunManager::setStun)
                    ::build);

    public static final RegistryObject<ComboState> DragonBoost = COMBO_STATES.register("dragon_boost",
            ComboState.Builder.newInstance().startAndEnd(400, 459).priority(50)
                    .motionLoc(DefaultResources.ExMotionLocation)
                    .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                    .nextOfTimeout(entity -> Pseudoedge_break_dawn.prefix("all_reuse"))
                    .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                            .put(1, (entityIn) -> AttackManager.doSlash(entityIn, 901F, Vec3.ZERO, false, false, 1F))
                            .put(2, (entityIn) -> DriveSumon.doSlash(entityIn, 45F, Vec3.ZERO,true, 5, 3, 10,16711680))
                            .put(3, (entityIn) -> SommonSwordSommon.doSlash(entityIn,16711680,true,15,3F,1,10,1))
                            .put(4, (entityIn) -> SommonSwordSommon.doSlash(entityIn,16711680,true,15,3F,1,10,1))
                            .put(5,(entityIn)->{
                                entityIn.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, 900, 3));
                                entityIn.addEffect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 900, 3));
                                entityIn.addEffect(new MobEffectInstance(MobEffects.NIGHT_VISION, 900, 3));

                            })
                            .build())
                    .addHitEffect(StunManager::setStun)
                    ::build);
    public static final RegistryObject<ComboState> BlackHole = COMBO_STATES.register("black_hole",
            ComboState.Builder.newInstance().startAndEnd(400, 459).priority(50)
                    .motionLoc(DefaultResources.ExMotionLocation)
                    .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                    .nextOfTimeout(entity -> Pseudoedge_break_dawn.prefix("all_reuse"))
                    .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                            .put(1, JudgementCut::doJudgementCutJust)
                            .put(3, (entityIn) -> SommonSwordSommon.doSlash(entityIn,16777215,true,15,3F,1,15,1))
                            .put(4, (entityIn) -> SommonSwordSommon.doSlash(entityIn,16777215,true,15,3F,1,15,1))
                            .build())
                    .addHitEffect(StunManager::setStun)
                    ::build);
    public static final RegistryObject<ComboState> kingblade = COMBO_STATES.register("kingblade",
            ComboState.Builder.newInstance().startAndEnd(400, 459).priority(50)
                    .motionLoc(DefaultResources.ExMotionLocation)
                    .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                    .nextOfTimeout(entity -> Pseudoedge_break_dawn.prefix("all_reuse"))
                    .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                            .put(1, (entityIn) -> AttackManager.doSlash(entityIn, 45F, Vec3.ZERO, false, false, 1F))
                            .put(2, (entityIn) -> AttackManager.doSlash(entityIn, -45F, Vec3.ZERO, false, false, 1F))
                            .put(3, (entityIn) -> AttackManager.doSlash(entityIn, 45F, Vec3.ZERO, false, false, 1F))
                            .put(4, (entityIn) -> AttackManager.doSlash(entityIn, -45F, Vec3.ZERO, false, false, 1F))
                            .put(5, (entityIn) -> DriveSumon.doSlash(entityIn, 45F,  Vec3.ZERO, false, 1F, 1f, (int) 10, 16711680))
                            .put(6, (entityIn) -> DriveSumon.doSlash(entityIn, -45F,  Vec3.ZERO, false, 1F, 1f, (int) 10, 16711680))
                            .put(7, (entityIn) -> DriveSumon.doSlash(entityIn, 45F,  Vec3.ZERO, false, 1F, 1f, (int) 10, 16711680))
                            .put(8, (entityIn) -> DriveSumon.doSlash(entityIn, -45F,  Vec3.ZERO, false, 1F, 1f, (int) 10, 16711680))

                            .build())
                    .addHitEffect(StunManager::setStun)
                    ::build);
    public static final RegistryObject<ComboState> Blackslash = COMBO_STATES.register("black_slash",
            ComboState.Builder.newInstance().startAndEnd(400, 459).priority(50)
                    .motionLoc(DefaultResources.ExMotionLocation)
                    .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                    .nextOfTimeout(entity -> Pseudoedge_break_dawn.prefix("all_reuse"))
                    .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                            .put(1, (entityIn) -> AttackManager.doSlash(entityIn, 90F, Vec3.ZERO, false, false, 1F))
                            .put(3, (entityIn) -> SommonSwordSommon.doSlash(entityIn,0,true,10,3F,1,15,1))
                            .put(4, (entityIn) -> SommonSwordSommon.doSlash(entityIn,0,true,10,3F,1,15,1))
                            .build())
                    .addHitEffect(StunManager::setStun)
                    ::build);
    public static final RegistryObject<ComboState> ThrustSlash = COMBO_STATES.register("thrustslash",
            ComboState.Builder.newInstance().startAndEnd(400, 459).priority(50)
                    .motionLoc(DefaultResources.ExMotionLocation)
                    .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                    .nextOfTimeout(entity -> Pseudoedge_break_dawn.prefix("all_reuse"))
                    .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                            .put(1, (entityIn) -> AttackManager.doSlash(entityIn, -30F, Vec3.ZERO, false, false, 0.1F))
                            .put(2, (entityIn) -> Thrust.doSlash(entityIn,3F*3))
                            .put(6, (entityIn) -> AttackManager.doSlash(entityIn, -45F, Vec3.ZERO, false, false, 1F))
                            .put(9, (entityIn) -> AttackManager.doSlash(entityIn, -45F, Vec3.ZERO, false, false, 3F))
                            .build())
                    .addHitEffect(StunManager::setStun)
                    ::build);
    public static final RegistryObject<ComboState> ThrustSlashEX = COMBO_STATES.register("thrustslash_ex",
            ComboState.Builder.newInstance().startAndEnd(400, 459).priority(50)
                    .motionLoc(DefaultResources.ExMotionLocation)
                    .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                    .nextOfTimeout(entity -> Pseudoedge_break_dawn.prefix("all_reuse"))
                    .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                            .put(1, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 180))
                            .put(2, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 90))
                            .put(3, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 0))
                            .put(4, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, -90))
                            .put(5, (entityIn) -> Thrust.doSlash(entityIn,3F*3))
                            .put(6, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 180))
                            .put(7, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 90))
                            .put(8, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 0))
                            .put(9, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, -90))                           .build())
                    .addHitEffect(StunManager::setStun)
                    ::build);
}
